<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1" import=java.io.* %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<%
class CookieStr implements Serializable{
	String msg;
	int number;
	int sessionID;
	int versionNumber;
	int localData;
	public CookieStr(String msg, int number, int sessionID, int versionNumber, int localData){
		this.msg = msg;
		this.number = number;
		this.sessionID = sessionID;
		this.versionNumber = versionNumber;
		this.localData = localData;
	}
};
	String cookieName = "5300COOKIE";
	Cookie cookies[] = request.getCookies();
	Cookie cookie = null;
	if (cookies != null) {
		for (int i = 0; i < cookies.length; i++) {
			if (cookies[i].getName().equals(cookieName)) {
				cookie = cookies[i];
				break;
			}
		}
	}
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>bh349 5300SimpleSite</title>
</head>
<body>

<%
	String msg;
	int number;
	int sessionID;
	int versionNumber;
	int localData;
	
	if (cookie == null) {
		CookieStr cstr = new CookieStr("Hello, user!", 1, 0, 0, 0);
		Cookie newCookie = new Cookie("5300COOKIE", cstr.toString()); 
		response.addCookie(newCookie);
	} else {
		
	}
	out.println("<h1>(" + number + ") " + msg + "</h1></br>");

	out.println("<form method = \"post\" action = \"replace.jsp\">"
			+ "<input type = \"submit\" value=\"replace\">"
			+ "<input type = \"text\" name=\"replaceMsg\"><br>"
			+ "</form>");
	out.println("<form method=\"post\" action=\"refresh.jsp\">"
			+ "<input type=\"submit\" value=\"refresh\"></br>"
			+ "</form>");
	out.println("<form method=\"post\" action=\"logoff.jsp\">"
			+ "<input type=\"submit\" value=\"logout\"></br>"
			+ "</form>");
%>
</body>
</html>